<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"  %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'page3.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

   <link rel="stylesheet" type="text/css" href="./jquery/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="./jquery/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="./jquery/demo.css">
	<script type="text/javascript" src="./jquery/jquery.min.js"></script>
	<script type="text/javascript" src="./jquery/jquery.easyui.min.js"></script>
	
	
	</head>
  <body style="background-color: #eee8aa;">
    	<p>导航栏可点击操作: 
    <div>
    	<c:forEach items="${req3}" var="r" varStatus="v">
    		<input type="hidden" value="${r.id}" id="a${v.index}a1">
    		
	  		<a title="点击操作" onclick="ds(this.id)" id="a${v.index}" onmousemove="bigImg(this.id)" onmouseout="normalImg(this.id)" >
    		<span >${v.index+1}.${r.text }
		 	 </span>
	  		<img alt="首页" src="/wifiIMG/icon/img1/${r.pic}" height="12%"></a>
		  <c:if test="${v.index==5||v.index==11||v.index==17}">
		  <p><br>
		  </c:if>
    	</c:forEach>
    	<button onclick="insertSbu(this.id)" id="a${v.index}" style="padding: 5px 20px; margin-left: 10px">添   加</button>
    </div>
    
    <hr>
    <p>图标可点击操作:
     <div style="font-weight: ">
    	<c:forEach items="${req4}" var="r1" varStatus="v">
    		<input type="hidden" value="${r1.id}" id="b${v.index}a2">
	  		<a  title="点击操作" onclick="ds(this.id)" id="b${v.index}" onmousemove="bigImg(this.id)" onmouseout="normalImg(this.id)">
    		<span >${v.index+1}.${r1.text }</span>
	  		<img alt="首页" src="/wifiIMG/icon/img1/${r1.pic}" height="8%"></a>
		  <c:if test="${v.index==8||v.index==17||v.index==26}">
		  <p><br>
		  </c:if> 
    	</c:forEach>
    	<button onclick="insertSbu(this.id)" id="b${v.index}" style="padding: 5px 20px; margin-left: 10px" >添   加</button>
    </div>
    
    
     
    <div id="win" style="display: none;">
    <div style="margin:40px 50px;font-weight: 700">
	    <form action="#" method="post" 
	    		enctype="multipart/form-data" onsubmit="return formSub()">
		   	<input type="hidden" name="type" id ="type" value="2">
		   	 文字:<input name="u.text" type="text" id="text"><p>
		 	网址:<input name="u.url" type="text" id="url"><p>
		 	图片:<input type ="file" name="file" id="file"/>
		 	<input type="hidden" name="u.page" id="page"/>
		 	<input type="hidden" name="u.rid" id="rid" />
		 	<input type="hidden" name="u.id" id="id"/>
		 	<input type="hidden" name="u.pic" id="pic"/>
		 	<input type="hidden" name="" id="caozuo">
		 	<input type="submit" value="保   存" style="padding-left: 22px;padding-right: 22px;margin-top: 30px"/>
		    <input type="button" value="删除" title="点击删除" onclick="shanchu()" id="del" />
	    </form>
    </div>
  </div>  
  </body>
  <script type="text/javascript">
  	function ds(id){
	  	var aa = id.slice(0,1);
	  	var value;
	  	if(aa=="a"){
	  		value = $("#"+id+"a1").val();
	  	}else{
	  		value = $("#"+id+"a2").val();
	  	}
	  		
  	 $.ajax({
		   type: "post",
		   url: "${pageContext.request.contextPath}/Guan/GuanLiUrl_getUrl.action",
		   data: {"id":value},
		   dataType:"json",
		   success: function(msg){
		    var obj = eval("("+msg+")");
		      $("#text").val(obj["text"]);
		      $("#url").val(obj["url"]);
		      $("#page").val(obj["page"]);
		      $("#rid").val(obj["rid"]);	      
		      $("#id").val(obj["id"]);	      
		      $("#pic").val(obj["pic"]);
		      $("#caozuo").val("xiugai");	      
		   	document.getElementById("win").style.display="block";
		    document.getElementById("del").style.visibility="visible";
		    $("form").prop("action","${pageContext.request.contextPath}/Guan/GuanLiUrl_updateImgUrl.action");
			  $('#win').window({    
			    width:320,    
			    height:280,    
			    modal:true ,
			    title:"存改操作",  
			    collapsible:false,
			    minimizable:false,
			    resizable:false,
			    maximizable:false,
			});
		   },
		   error:function(){
		   		alert("系统出错误,请联系技术人员");
		   }
		});
 	}
 	
 	function shanchu(){
 		 var r=confirm("确定删除吗");
	  if (r==true)
	    {
	    	 var uid = $("#id").val();
	    	 var pic = $("#pic").val();
	 		 var rid = $("#rid").val();
	 		 var page = $("#page").val();
	 		 var type = $("#type").val();
 			window.location.href="${pageContext.request.contextPath }/Guan/GuanLiUrl_deleteImgUrl.action?u.id="
 			+uid+"&u.rid="+rid+"&u.page="+page+"&type="+type+"&u.pic="+pic;
	    }
	   return false; 
 	}
 	function bigImg(id){
 		$("#"+id).css({"font-weight":"900"});
 	}
 	function normalImg(id){
 		$("#"+id).css({"font-weight":500});
 	}
 	
 	
 	function insertSbu(id){
 		var aa = id.slice(0,1);
	  	var value;
	  	if(aa=="a"){
	  		$("#rid").val("3");
	 		 $("#page").val("1");
	  	}else{
	  		$("#rid").val("4");
	 		$("#page").val("1");
	  	}
	 		$("#caozuo").val("tianjia");
 		
 		$("#text").val("");
 		$("#url").val("");
 		document.getElementById("del").style.visibility="hidden";
 		document.getElementById("win").style.display="block";
		$("form").prop("action","${pageContext.request.contextPath }/Guan/GuanLiUrl_insertImgUrl.action");
			  $('#win').window({    
			    width:320,    
			    height:280,    
			    modal:true ,
			    title:"存改操作",  
			    minimizable:false,
			    collapsible:false,
			    minimizable:false,
			    resizable:false,
			    maximizable:false,
			});
 	}
 	function formSub(){
 		var caozuo =$("#caozuo").val();
		var text = $("#text").val();
		var url = $("#url").val();
 		var file = 	$("#file").val();
 		if(caozuo=="xiugai"){
 			if(text!=""&&url!=""){
 				return true;
 			}else{
 				alert("名称和网址不能为空!");
 				return false;
 			}
 		}
 		if(caozuo=="tianjia"){
 			if(text!=""&&url!=""&&file!=""){
 				return true;
 			}else{
 				alert("所有内容不能为空!");
 				return false;
 			}
 		}
 	}
 	
  </script>
</html>
